package com.clothing.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.clothing.CommonAttributes;
import com.clothing.utils.Utils;

/**
 * @ClassName: ArticleType
 * @Description: TODO(Entity-ArticleType)
 * @author Charles.Tao
 * @date 2017年8月21日 下午4:15:41
 * @version 1.0
 */
@Entity
@Table(name = "article_type")
public class ArticleType extends OrderEntity
{
    private static final long serialVersionUID = 6889853035520803064L;

    private String name;

    private String icon;
    
    private Boolean isShow;
    
    @Column(name = "name", nullable = false)
    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    @Column(name = "icon", nullable = false)
    public String getIcon()
    {
        return icon;
    }

    public void setIcon(String icon)
    {
        if (!Utils.isEmpty(icon))
        {
            if (icon.startsWith(CommonAttributes.SITE_URL))
            {
                icon = icon.substring(CommonAttributes.SITE_URL.length(),
                        icon.length());
            }
        }

        this.icon = icon;
    }
    
    @Column(name = "is_show", nullable = false)
    public Boolean getIsShow()
    {
        return isShow;
    }

    public void setIsShow(Boolean isShow)
    {
        this.isShow = isShow;
    }
    
    @Transient
    public String getFullIcon()
    {
        if (!Utils.isEmpty(icon))
        {
            return CommonAttributes.SITE_URL + icon;
        }

        return null;
    }
}
